package com.sn.controller;

import com.sn.service.NewsService;
import com.sn.vo.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("news")
public class NewsController {
    @Autowired
    NewsService newsService;

    @PostMapping("list")
    public Result getAll(@RequestBody PageParams pageParams){
        System.out.println(pageParams);
        return newsService.findAll(pageParams);
    }

    @GetMapping("getBySid/{sId}")
    public Result getBySid(@PathVariable("sId") Integer sId){
//        System.out.println(sId);
        return newsService.catchBySid(sId);

    }
    @PostMapping("delete")
    public Result deleteByNids(@RequestBody List<Integer> nIds){
//        System.out.println(nIds);//[2, 3]
        return newsService.deleteByNids(nIds);
    }
}
